#coding=utf-8
'''
re.sub 替换
'''

import re


language = 'PythonC#JavaPHP'
result = re.sub('C#','GO',language)


'''
在sub中对需要替换的数字做函数处理，如果大于６，替换为９，否则替换为０
'''
s = 'A8C3721D86'

def convert(value):
    matched = value.group()
    if int(matched) >= 6:
        return '9'
    else:
        return '0'

result = re.sub('\d',convert,s)
print(result)